package io.github.biezhi.wechat.controller;


import io.github.biezhi.wechat.service.WeChatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author wangsh
 * @date 2019-07-05 15:47
 */
@Controller
public class WeChatController {

    @Autowired
    private WeChatService weChatService;

    @Value("${wechat.codePath}")
    private String codePath;

    @GetMapping(value = "/login")
    @ResponseBody
    public String login(){
        weChatService.demo();
        return "login";
    }

    @GetMapping(value = "/index")
    public String index(Model model){
        model.addAttribute("codeSrc",codePath + "?p=" + Math.random());
        return "index";
    }


}
